<template>
	<view>
		<Seller :shopList='shopList' />
		<Tabs />
	</view>
</template>

<script>
	import Seller from './components/seller.vue'
	import Tabs from './components/tabs.vue'

	import {
		discuss,
		shop,
		getdishes
	} from '../../api/api/forshop.js'

	export default {
		components: {
			Seller,
			Tabs
		},
		data() {
			return {

				shopList: [],
				discussList: [],
				getdishesList: [],
				// wxlogin: true,
				loginData: {}

			}
		},
		onLoad(options) {
			// console.log('options', options)
			this.requestAll(options.openid)

		},

		methods: {
			async requestAll(openid) {

				const res = await Promise.all([discuss({
						merchantid: openid
					}), shop({
						openid
					}),
					getdishes({
						openid
					})
				])
				let array = []
				res[0].data.forEach(item => {
					if (item.classmessage) {
						array.push(item.classmessage)
					}
				})
				//添加属性 后面计算金额需要用到
				res[2].data.forEach(item => {
					item.objdis.number = 0
					item.objdis.count = 0
				})
				array.unshift('全部')
				// let classmessage=

				this.$store.commit('setClassmessageList', [...new Set(array)])
				this.$store.commit('setMerchantid', res[0].data[0].merchantid)
				this.$store.commit('setDiscussList', res[0].data)
				this.$store.commit('setShopList', res[1].data[0])

				this.$store.commit('setGetdishesList', res[2].data)


			},


		},

	}
</script>

<style scoped lang="scss">

</style>
F
